package com.imay.live.view.banner;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.imay.base.util.ViewUtil;
import com.imay.live.R;

/**
 * Created by lzx on 2017/07/10 0010.
 */

public class BannerLayout extends LinearLayout {
    ImageView imageView;
    int h;

    public BannerLayout(Context context, int h) {
        super(context);
        this.h = h;
        init();
    }

    public ImageView getImageView() {
        return imageView;
    }

    private void init() {
        setOrientation(LinearLayout.VERTICAL);
        ImageView bg = new ImageView(getContext());
        imageView = new ImageView(getContext());
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        bg.setBackground(getResources().getDrawable(R.mipmap.bg_02banneryin));
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        params.weight = 1;

        LinearLayout.LayoutParams bgparams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getshawH());
        addView(imageView, params);
        addView(bg, bgparams);
    }

    public static float getshawH() {
        float w = ViewUtil.mScreemWidth * MindleViewPager.VIEW_SCALE * MindleViewPager.MAX_SCALE;
        return w * 51 / 801;
    }
}
